package sc.dao;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

import sc.vo.Department;

public class DepartmentDAO implements InterfaceDAO<Department> {
	private ArrayList<Department> lists;
	@Override
	public void insertItem(Department item) {
		if(!lists.contains(item)) {
			lists.add(item);
		} else {
			System.out.println("해당 학과는 이미 존재합니다.");
		}
	}

	@Override
	public void updateItem(Department item) {
		if(lists.contains(item)) {
			lists.set(lists.indexOf(item), item);
		} else {
			System.out.println("해당 학과는 존재하지 않습니다.");
		}
	}

	@Override
	public void deleteItem(Department item) {
		if(lists.contains(item)) {
			lists.remove(item);
		} else {
			System.out.println("해당 학과는 존재하지 않습니다.");
		}
	}

	@Override
	public Department searchItem(Department item) {
		return lists.get(lists.indexOf(item));
	}

	@Override
	public void prnListItem(Comparator<Department> comp) {
		if(comp == null) {
			Collections.sort(lists);
		} else {
			Collections.sort(lists, comp);
		}
 		
		for(Department dept : lists) {
			System.out.println(dept);
		}
	}

	@Override
	public Connection loadDB() {
		Connection con = null;
		
		return con;
	}

	@Override
	public void closeDB() {
		
	}

	@Override
	public ArrayList<Department> list() {
		// TODO Auto-generated method stub
		return null;
	}
}